package com.bibi.hanshunping.chapter06;

import java.lang.reflect.Array;
import java.util.Arrays;

public class Array01 {
    public static void main(String[] args) {
        /*double c1= 2;
        double c2= 3;
        double c3= 5;
        double c4= 6;
        double c5= 9;
        double sum = c1 + c2 + c3 + c4 + c5;
        double avg = sum / 5;*/

        // 使用数组的方式
        double sum = 0, avg = 0;
        double[] hens = {1, 2, 3, 4, 6};
        for (int i = 0; i < hens.length; i++) {
            System.out.println(hens[i]);
            sum += hens[i];
        }
        for (double hen :
                hens) {
            System.out.println(hen);
        }
        avg = sum / hens.length;
        System.out.println(hens);
        System.out.println(sum);
        System.out.println(avg);
    }
}
